import QtQuick 2.6
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
Popup {
    id: systemWindow
    padding: 0
    margins: 0
    modal: false
    focus: true
    closePolicy: Popup.NoAutoClose
    width: Screen.desktopAvailableWidth
    height: Screen.desktopAvailableHeigh
    opacity: 0
  //  visible: false


    property bool isdump: false
    property bool showFlag: false

    property string title: qsTr("BaseWindow")

    function show(){
        open()
    }

    function showNormal(){
        open()
    }

    function requestActivate()
    {
        forceActiveFocus()
    }


    ParallelAnimation{
        id: winoutani
        running: false
        NumberAnimation { target: systemWindow; property: "opacity"; to: 0; duration: 600}

        onRunningChanged: {
            console.log("x:" + x +"y:"+y);
            console.log(systemWindow+" is running:" + running)
        }
        onStopped: {
            close.accepted = true;
            systemWindow.close()
        }
    }

    ParallelAnimation {
        id: wininani
        running: true
        NumberAnimation { target: systemWindow; property: "opacity"; to: 1.0; duration: 200}
        NumberAnimation { target: systemWindow; property: "x"; to: -640; duration: 200}
        NumberAnimation { target: systemWindow; property: "y"; to: -360; duration: 200}
        onRunningChanged: {
            console.log("x:" + x);
            console.log("y:"+y);
        }
        onStopped: {
//            tickWnd.close()
            console.log(systemWindow+"opened")
        }
    }

    Component.onCompleted: {
//        loader.source = ""
        console.log("onCompleted")
//        wininani.start();
    }

    onAboutToHide: {
//        close.accepted = false;
        console.log("closing window")
        showFlag = false
        winoutani.start()
    }

    onAboutToShow: {
        wininani.start();
    }

    onVisibleChanged: {
        if(isdump){console.log("onVisibleChanged: visible= "+ systemWindow.visible +" visibility=" +systemWindow.visibility)}
    }
    onWidthChanged: {
        if(isdump){console.log("onWidthChanged")}
    }

    onXChanged: {
        if(isdump){console.log("onXChanged")}
    }
    onYChanged: {
        if(isdump){console.log("onYChanged")}
    }
}
